﻿<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="center.aspx.cs" Inherits="Donal.Xms.Web.qianyi.center" %>

<%@ Import Namespace="Donal.Xms.Common" %>

<!DOCTYPE html>
<html>
<head>
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
    <meta name="viewport" content="width=device-width,minimum-scale=1.0,maximum-scale=1.0,initial-scale=1.0,user-scalable=no" />
    <meta name="apple-mobile-web-app-capable" content="yes" />
    <title>管理首页</title>
    <link rel="stylesheet" type="text/css" href="skin/icon/iconfont.css" />
    <link rel="stylesheet" type="text/css" href="skin/default/style.css" />
    <script type="text/javascript" charset="utf-8" src="../scripts/jquery/jquery-1.11.2.min.js"></script>
    <script type="text/javascript" charset="utf-8" src="js/layindex.js"></script>
    <script type="text/javascript" charset="utf-8" src="js/common.js"></script>

    <script type="text/javascript">
        //全局变量声明
        var isLock = false; //是否锁定正在执行操作
        var dialogDG; //dialog窗口实例

        //①提示且生成相应的频道
        function builerTip() {
            //检查是否正在执行操作
            if (isLock) {
                top.dialog({
                    title: '提示',
                    content: '上次操作未完成，不可同时执行！',
                    okValue: '确定',
                    ok: function () { }
                }).showModal();
                return false;
            }
            //提示是否执行
            top.dialog({
                title: '提示',
                content: '此操作将会消耗大量的资源，确认要继续吗？',
                okValue: '确定',
                ok: function () {
                    getBuilerUrl();
                },
                cancelValue: '取消',
                cancel: function () { }
            }).showModal();
        }
        //②发送AJAX请求获取生成地址
        function getBuilerUrl() {
            //如dialog窗口不存在则创建
            if (!dialogDG) {
                createDialogObj();
            }
            //重置dialog窗口的值
            dialogDG.find('.title h2').html('正在获取信息...');
            dialogDG.find('.content').html('正在加载，请稍候...');
            isLock = true; //锁定操作                       

            start_building();
        }

        //③迭代执行生成
        function execBuilerHtml(k) {

            k = k + 1;

            $.ajax({
                url: "/tools/admin_ajax.ashx?action=get_building_url&v=" + new Date().getTime(),
                type: "POST",
                dataType: "json",
                error: function () {
                    getBuilerStatus(jsonUrl, k, "需要生成的静态页面路径有误！");
                },
                success: function (data) {
                    if (data.status == 1) {
                        getBuilerStatus(data.msg, k, 0);
                    } else {
                        isLock = false; //解除锁定

                        let infor = dialogDG.find('.title h2').html();
                        dialogDG.find('.title h2').html(infor + " 全部完成！！！");

                        //完成提示
                        var d = top.dialog({ content: '页面全部生成完毕' }).show();
                        setTimeout(function () {
                            d.close().remove();
                        }, 2000);
                    }

                }
            });
        }

        //④返回执行结果及状态
        function getBuilerStatus(jsonUrl, k, msg) {

            var spanTxt = msg == 0 ? '<span class="suc">成功</span>' : '<span class="error">失败</span>';
            var linkTxt = spanTxt + '<a href="<%=sysConfig.webpath %>' + jsonUrl + '" target="_blank">/' + jsonUrl + '</a>';

            dialogDG.find('.title h2').html('已完成页面生成' + '[' + (k + 1) + ']');
            if (dialogDG.find('.content .list').length == 0) {
                dialogDG.find('.content').html('');
            }

            dialogDG.find('.content').append('<div class="list">' + linkTxt + '</div>');

            execBuilerHtml(k);
        }
        //创建dialog窗口
        function createDialogObj() {
            dialogDG = $('<div id="buildDialog" class="builder-box">'
                + '<div class="title">'
                + '<a class="close" onclick="closeDialogObj();"><i class="iconfont icon-remove"></i></a>'
                + '<h2>请稍候...</h2></div>'
                + '<div class="content"></div></div>');
            dialogDG.appendTo($('body'));
        }
        //删除dialog窗口
        function closeDialogObj() {
            dialogDG.remove();
            dialogDG = null;
        }

        function start_building() {
            $.ajax({
                url: '/tools/admin_ajax.ashx?action=start_building',
                type: "POST",
                dataType: "json",
                success: function (data) {
                    if (data.status == 1) {
                        execBuilerHtml(0);
                    }
                }
            });
        }
    </script>

</head>

<body class="mainbody">
    <form id="form1" runat="server">
        <!--导航栏-->
        <div class="location">
            <a href="javascript:history.back(-1);" class="back"><i class="iconfont icon-up"></i><span>返回上一页</span></a>
            <a href="javascript:;"><i class="iconfont icon-home"></i><span>首页</span></a>
            <i class="arrow iconfont icon-arrow-right"></i>
            <span>管理中心</span>
        </div>
        <!--/导航栏-->

        <!--内容-->
        <div class="line10"></div>
        <div class="nlist-1">
            <ul>
                <li>
                    <p>本次登录IP：<asp:Literal ID="litIP" runat="server" Text="-" /></p>
                </li>
                <li>
                    <p>上次登录IP：<asp:Literal ID="litBackIP" runat="server" Text="-" /></p>
                </li>
                <li>
                    <p>上次登录时间：<asp:Literal ID="litBackTime" runat="server" Text="-" /></p>
                </li>
            </ul>
        </div>
        <div class="line10"></div>

        <div class="nlist-2">
            <h3><i class="iconfont icon-setting"></i>站点信息</h3>
            <ul>
                <li>
                    <p>站点名称：<%=sysConfig.webname %></p>
                </li>
                <li>
                    <p>公司名称：<%=sysConfig.webcompany %></p>
                </li>
                <li>
                    <p>主站域名：<%=sysConfig.weburl %></p>
                </li>
                <li>
                    <p>安装目录：<%=sysConfig.webpath %></p>
                </li>
                <li>
                    <p>网站管理目录：<%=sysConfig.webmanagepath %></p>
                </li>
                <li>
                    <p>附件上传目录：<%=sysConfig.filepath %></p>
                </li>
                <li>
                    <p>服务器名称：<%=Server.MachineName%></p>
                </li>
                <li>
                    <p>服务器IP：<%=Request.ServerVariables["LOCAL_ADDR"] %></p>
                </li>
                <li>
                    <p>NET框架版本：<%=Environment.Version.ToString()%></p>
                </li>
                <li>
                    <p>操作系统：<%=Environment.OSVersion.ToString()%></p>
                </li>
                <li>
                    <p>IIS环境：<%=Request.ServerVariables["SERVER_SOFTWARE"]%></p>
                </li>
                <li>
                    <p>服务器端口：<%=Request.ServerVariables["SERVER_PORT"]%></p>
                </li>
                <li>
                    <p>目录物理路径：<%=Request.ServerVariables["APPL_PHYSICAL_PATH"]%></p>
                </li>
                <li>
                    <p>系统版本：V<%=Utils.GetVersion()%></p>
                </li>
                <li>
                    <p>版本更新：<asp:Literal ID="LitUpgrade" runat="server" /></p>
                </li>
            </ul>
        </div>
        <div class="line20"></div>

        <div class="nlist-3" style="width: 450px;">
            <ul>
                <li style="width: 20%;"><a onclick="parent.linkMenuTree(true, 'sys_config');" href="javascript:;"><i class="iconfont icon-setting"></i></a><span>系统设置</span></li>
                <li style="width: 20%;"><a onclick="parent.linkMenuTree(true, 'sys_site_manage');" href="javascript:;"><i class="iconfont icon-site"></i></a><span>站点管理</span></li>
                <li style="width: 20%;"><a onclick="builerTip(this);" href="javascript:;"><i class="iconfont icon-build"></i></a><span>生成静态</span></li>
                <li style="width: 20%;"><a onclick="parent.linkMenuTree(true, 'manager_list');" href="javascript:;"><i class="iconfont icon-manager"></i></a><span>管理员</span></li>
                <li style="width: 20%;"><a onclick="parent.linkMenuTree(true, 'manager_log');" href="javascript:;"><i class="iconfont icon-log"></i></a><span>系统日志</span></li>
            </ul>
        </div>

        <!--/内容-->
    </form>
</body>
</html>
